home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / daemons / nfs / nfs-serv.2be / nfs-serv / nfs-server-2.2beta16 / fh.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-09-20  |  4.0 KB  |  135 lines

  1. /*
  2.  * fh.h        This module handles the file-handle cache.
  3.  *
  4.  * Authors:    Mark A. Shand, May 1988
  5.  *        Don Becker, <becker@super.org>
  6.  *        Rick Sladkey, <jrs@world.std.com>
  7.  *        Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
  8.  *
  9.  *        Copyright 1988 Mark A. Shand
  10.  *        This software maybe be used for any purpose provided
  11.  *        the above copyright notice is retained.  It is supplied
  12.  *        as is, with no warranty expressed or implied.
  13.  */
  14.  
  15. /* Compatibility between mount and nfs_prot. */
  16. #ifndef NFS_FHSIZE
  17. #   define NFS_FHSIZE        FHSIZE
  18. #endif
  19.  
  20. #define    HP_LEN            (NFS_FHSIZE - sizeof(u_long))
  21.  
  22. #define    FHC_XONLY_PATH        001    /* NOT USED ANYMORE */
  23. #define    FHC_BUSY        002    /* NOT USED */
  24. #define FHC_NFSMOUNTED        004
  25.  
  26. /* Modes for fh_find */
  27. enum {
  28.     FHFIND_FEXISTS = 0,    /* file must exist */
  29.     FHFIND_FCREATE,        /* file will be created */
  30.     FHFIND_FCACHED,        /* fh must be in cache */
  31. };
  32.  
  33. /*
  34.  * This defines the maximum number of handles nfsd will cache.
  35.  */
  36. #define    FH_CACHE_LIMIT        2000
  37.  
  38. /*
  39.  * This defines the maximum number of file nfsd may keep open for NFS I/O.
  40.  * It used to be 8...
  41.  */
  42. #define FD_CACHE_LIMIT        (3*FOPEN_MAX/4)
  43.  
  44. /* The following affect cache expiry.
  45.  * CLOSE_INTERVAL applies to the closing of inactive file descriptors
  46.  * The fd expiry interval is actually quite low because we want to have big
  47.  * files actually go away when they have been deleted behind our back. 
  48.  * We also want to be able to execute programs that have just been copied
  49.  * via NFS.
  50.  *
  51.  * DISCARD_INTERVAL is the time in seconds nfsd will cache file handles
  52.  * unless it's being flooded with other requests. This value is possibly
  53.  * still too large, but the original was 2 days.        --okir
  54.  */
  55. #define FLUSH_INTERVAL        5            /* 5 seconds    */
  56. #define BUSY_RETRY_INTERVAL    2            /* 2 seconds    */
  57. #define CLOSE_INTERVAL        5            /* 5 seconds    */
  58. #define DISCARD_INTERVAL    (60*60)            /* 1 hour    */
  59.  
  60.  
  61. /*
  62.  * Hashed search path to this file.
  63.  * path is: hash_path[1] ... hash_path[hash_path[0]]
  64.  *
  65.  * hash_path[hash_path[0]+1] ... hash_path[HP_LEN-1] == 0
  66.  */
  67. typedef struct {
  68.   u_long    psi;
  69.   u_char    hash_path[HP_LEN];
  70. } svc_fh;
  71.  
  72. typedef enum { inactive, active } mutex;
  73.  
  74. /*
  75.  * Paths constructed in this system always consist of real directories
  76.  * (excepting the last element) i.e. they do not contain symbolic links.
  77.  * This is guaranteed by the way NFS constructs the paths.
  78.  * As a consequence we may assume that
  79.  *    /x/y/z/.. == /x/y
  80.  * and    /x/y/z/. == /x/y/z
  81.  * provided that z != . && z != ..
  82.  * These relations are exploited in fh_compose.
  83.  *
  84.  * Further assumptions:
  85.  *    All cached pathnames consist of a leading /
  86.  *    followed by zero or more / separated names
  87.  *    s.t.
  88.  *        name != .
  89.  *        name != ..
  90.  *        index(name, '/') == 0
  91.  */
  92. typedef struct fhcache {
  93.   struct fhcache    *next;
  94.   struct fhcache    *prev;
  95.   struct fhcache    *hash_next;
  96.   struct fhcache    *fd_next;
  97.   struct fhcache    *fd_prev;
  98.   svc_fh        h;
  99.   int            fd;
  100.   int            omode;
  101.   char            *path;
  102.   time_t        last_used;
  103.   nfs_client        *last_clnt;
  104.   nfs_mount        *last_mount;
  105.   uid_t            last_uid;
  106.   int            flags;
  107. } fhcache;
  108.  
  109. /* Global FH variables. */
  110. extern int _rpcpmstart;
  111. extern int fh_initialized;
  112.  
  113. /* Global function prototypes. */
  114. extern _PRO( enum nfsstat nfs_errno, (void)                );
  115. extern _PRO( int pseudo_inode, (u_long inode, u_short dev)        );
  116. extern _PRO( void fh_init, (void)                    );
  117. extern _PRO( char *fh_pr, (nfs_fh *fh)                    );
  118. extern _PRO( int fh_create, (nfs_fh *fh, char *path)            );
  119. extern _PRO( fhcache *fh_find, (svc_fh *h, int create)            );
  120. extern _PRO( char *fh_path, (nfs_fh *fh, nfsstat *status)        );
  121. extern _PRO( int path_open, (char *path, int omode, int perm)        );
  122. extern _PRO( int fh_fd, (fhcache *fhc, nfsstat *status, int omode)    );
  123. extern _PRO( void fd_inactive, (int fd)                    );
  124. extern _PRO( nfsstat fh_compose, (diropargs *dopa, nfs_fh *new_fh,    \
  125.                   struct stat **sbpp, int fd, int omode));
  126. extern _PRO( int fh_psi, (nfs_fh *fh)                    );
  127. extern _PRO( void fh_remove, (char *path)                );
  128. extern _PRO( nfs_fh *fh_handle, (fhcache *fhc)                );
  129. extern _PRO( void fh_flush, (int force)                    );
  130. extern _PRO( RETSIGTYPE flush_cache,(int sig)                );
  131. extern _PRO( int nfsmounted, (const char *path, struct stat *sbp)    );
  132.  
  133. /* End of fh.h. */
  134.  
  135.